﻿//-----------------------------------------------------------------------
// <copyright file="IUnitOfWork.cs" company="SLWY Enterprises">
// * Copyright (C) 2017 四川商旅无忧科技有限公司 版权所有。
// * version : 1.0
// * author  : qinchaoyue
// * FileName: IUnitOfWork.cs
// * history : created by qinchaoyue 2017-10-26 02:49:37
// </copyright>
//-----------------------------------------------------------------------

using System;
using Slwy.FrameCore.Dependency;

namespace Slwy.Data.Entity.Interfaces
{
    using System.Collections.Generic;
    using SqlSugar;

    /// <summary>
    /// The UnitOfWork interface.
    /// </summary>
    public interface IUnitOfWork : IScopeDependency
    {
        /// <summary>
        /// 设置事务开关
        /// </summary>
        void SetTransactionEnabled(bool value, string dbName);

        Func<SqlSugarClient, string, bool> OnSaveChanged { get; set; }

        IDictionary<string, string> DbTables { get; set; }

        /// <summary>
        /// 获取事务开关
        /// </summary>
        /// <param name="dbName"></param>
        /// <returns></returns>
        bool GetTransactionEnabled(string dbName);

        /// <summary>
        /// 库
        /// </summary>
         IDictionary<string, SqlSugarClient> DbSet { get; set; }

        /// <summary>
        /// 提交当前单元操作的更改。
        /// </summary>
        /// <returns>操作影响的行数</returns>
        bool SaveChanges(string dbName);
    }
}